import { saveModel } from 'modules/tvaPlugin';
import { model } from 'tva';

// 通过model添加新数据
// eslint-disable-next-line
export default model({
    namespace: 'homeHead',
    state: {
        // 通过ts-type定义数据类型
        /** @type {Array<{url: string, name: string, buoy: string}>} */
        module: [],

        /** @type {{image: string, url: string}} */
        mainActivity: null,

        banner: [],
    },

    plugin: [saveModel()],
    reducer: {
        updateState(draft, { data }) {
            draft.module = data.module;
            draft.banner = data.banner;
            draft.mainActivity = data.mainActivity;
        },
    },
});

/**
 * @returns {state}
 */
export function getHomeHeadModel(any) {
    return any;
}
